/*
 * @Author       : xiaowu wwl093000@163.com
 * @Date         : 2023-06-27 14:38:55
 * @LastEditTime : 2023-06-27 14:39:01
 * @LastEditors  : xiaowu wwl093000@163.com
 * @FilePath     : /erp-admin-ui/src/utils/dataURLtoFile.js
 * @Description  : -
 */
/**
 * dataurl: base64
 * filename: 设置文件名称
 */
export const dataURLtoFile = (dataurl, filename) => {
  let arr = dataurl.split(','),
    mime = arr[0].match(/:(.*?);/)[1],
    bstr = atob(arr[1]),
    n = bstr.length,
    u8arr = new Uint8Array(n);
  while (n--) {
    u8arr[n] = bstr.charCodeAt(n);
  }
  return new File([u8arr], filename, {
    type: mime
  });
}
